<?php

namespace App\Http\Middleware;

use Illuminate\Http\Request;
use Inertia\Middleware;

class HandleInertiaRequests extends Middleware
{
    protected $rootView = 'web';

    public function share(Request $request): array
    {
        $this->rootView($request);
        return [
            ...parent::share($request),
            'rootView' => $this->rootView,
            'config' => [
                'name' => '预约收银系统',
                'logo' => 'https://www.yuxibs.com/static/images/logo.png',
            ]
        ];
    }

    public function rootView(Request $request): string
    {
        $prefix = explode('.', $request->route()->getName())[0] ?? 'web';
        return $this->rootView = $prefix;
    }
}
